package com.smasher.component.fragment

import android.annotation.SuppressLint
import android.view.View
import android.view.ViewGroup
import com.smasher.dialog.select.BaseSelectDialog
import com.smasher.dialog.select.delegate.ElementShowDelegate
import com.smasher.dialog.select.adapter.SelectAdapter
import com.smasher.dialog.select.SelectMode

class TestDialog : BaseSelectDialog<String>() {

    override fun initView() {

    }

    @SuppressLint("NotifyDataSetChanged")
    override fun initData() {
        setData(List(100) { "Android $it" })
        mode = SelectMode.MULTI
        mAdapter.setData(mList)
        mAdapter.notifyDataSetChanged()
        mHelper.stateNormal()
    }

    override fun getWidth(): Int {
        return ViewGroup.LayoutParams.MATCH_PARENT
    }

    override fun getHeight(): Int {
        return ViewGroup.LayoutParams.MATCH_PARENT
    }

    override fun createAdapter(delegate: ElementShowDelegate<String>): SelectAdapter<String> {
        return SelectAdapter(elementShowDelegate = delegate)
    }

    /**
     * 创建展示代理
     * @return ElementShowDelegate
     */
    override fun createShowDelegate(): ElementShowDelegate<String> {
        return object : ElementShowDelegate<String>() {

            override fun showMainTitle(element: String): String {
                return element
            }

            override fun showSubTitle(element: String): String {
                return ""
            }

            override fun bindShowingView(element: String, view: View) {

            }
        }
    }

    override fun reload() {

    }
}